package com.aigou.controller;

import com.aigou.dao.BrandMapper;
import com.aigou.dao.UserMapper;
import com.aigou.dao.UserMenuMapper;
import com.aigou.pojo.Brand;
import com.aigou.pojo.Result;
import com.aigou.pojo.UserMenu;
import com.aigou.vo.UserMenuVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/user/menu")
@CrossOrigin
public class UserMenuController {

    @Autowired
    UserMenuMapper userMenuMapper;

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    @ResponseBody
    public Result findAll(@RequestBody UserMenuVo umv) {

        Result result = new Result();

        for (Integer mid : umv.getMids()) {
            UserMenu um = new UserMenu();
            um.setUid(umv.getUid());
            um.setMid(mid);
            userMenuMapper.insert(um);
        }

        return result;
    }

}
